/**
 *
 */
package de.cbf.cam.dsa.rcp.model.entities.items;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;

import de.cbf.cam.dsa.item.model.entities.constants.QualityConstants;
import de.cbf.util.uuidheader.entities.UUIDHeader;
import de.cbf.util.uuidheader.entities.UUIDReference;
import de.cbf.util.uuidheader.exceptions.EntityMergeException;

/**
 * @author salter
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
public class ItemForProfession extends UUIDHeader {

	@XmlElement(name="reference")
	private UUIDReference itemReference;

	protected Double desiredQuality;
	/**
	 *
	 */
	public ItemForProfession() {
		init();
	}

	protected void init() {
		desiredQuality = QualityConstants.QUALITY_COMMON;
	}

	@Override
	protected void doMergeDataFrom(UUIDHeader entity, boolean i_am_older)
			throws EntityMergeException {
		if (entity instanceof ItemForProfession) {
			ItemForProfession other = (ItemForProfession) entity;
			if(i_am_older){
				this.itemReference = other.itemReference;
				this.desiredQuality	= other.desiredQuality;
			}
		}else{
			String mergeEntityClass = entity == null? "null":entity.getClass().getName();
			String errorMsg ="EntityToMerge "+mergeEntityClass+" does not fit class:"+this.getClass().getName();
			throw new EntityMergeException(errorMsg);
		}
	}

	public UUIDReference getItemReference() {
		return itemReference;
	}

	public void setItemReference(UUIDReference itemReference) {
		this.itemReference = itemReference;
	}

	public Double getDesiredQuality() {
		return desiredQuality;
	}

	public void setDesiredQuality(Double desiredQuality) {
		this.desiredQuality = desiredQuality;
	}


}
